#ifndef GAME2_H
#define GAME2_H

#include <QWidget>
#include "acquaintance.h"
#include "tip.h"

namespace Ui {
class Game2;
}

class Game2 : public QWidget
{
    Q_OBJECT

public:
    explicit Game2(QWidget *parent = nullptr);
    ~Game2();
    tip *t1=new tip();

private:
    Ui::Game2 *ui;
    QPoint offset;//存储鼠标与label位置差值
    int lastcellx=-1,lastcelly=-1;//存储鼠标移动事件中上一个细胞位置
    int startcellx=-1,startcelly=-1;//存储即将改变的矩形起点
    bool startcell=false;
    acquaintance *a;

protected:
    void paintEvent(QPaintEvent *event);
    void timerUpdate();
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);

private slots:
    void on_startpushButton_clicked();
    void on_pausepushButton_clicked();
    void on_backpushButton_clicked();
    void on_tippushButton_clicked();
};

class map3
{

private:
    int map[100][100]={};//存活状态 1为存活
    int neighbor[100][100];//邻居细胞个数
    int width=15; //细胞大小
    int height=15;
    int widthnum=48; //细胞个数
    int heightnum=48;

public:
    map3();
    ~map3(){};
    int getwidth(){return width;};
    int getheight(){return height;};
    int getwidthnum(){return widthnum;};
    int getheightnum(){return heightnum;};
    void changemap(int x,int y){map[x][y]=1;};//只能放置
    int getmap(int x,int y){return map[x][y];};
    void mapupdate();
    void mapclear();
    void renewmap();
    int mapclearcheck();
};

#endif // GAME2_H
